<?php

namespace App\Models\Exm;

use Illuminate\Database\Eloquent\Model;
use Laracasts\Presenter\PresentableTrait;

class Warehouse extends Model
{
	use PresentableTrait;

	protected $table = 'exm_warehouses';

	protected $presenter = 'App\Http\Presenters\WarehousePresenter';

    protected $guarded = array();

    /*
    答题参与用户
     */
    public function users()
    {
        return $this->hasMany('\App\Models\Exm\Auser');
    }

    /*
    题库池
     */
    public function items()
    {
        return $this->hasMany('\App\Models\Exm\Item')->where('status', STATUS_NORMAL);
    }

    /*题目*/
    public function questions()
    {
        return $this->hasManyThrough(
            '\App\Models\Exm\Question','\App\Models\Exm\Item',
            'id','id',
            'id','question_id');
    }

    public function activity()
    {
        return $this->belongsTo('\App\Models\Mgt\Activity');
    }
}